<html>
<head>
<title>asdasd</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
</head>
<body>
<form id="setup" name="setup">
<div>
<label for="url">Address:</label>
<input type="text" id="url" name="url"/>
</div>
<div>
<label for="requestType">Request Type:</label>
<input type="radio" name="requestType" id="requestTypeGET" value="GET"><label for="requestTypeGET">Get</label>
<input type="radio" name="requestType" id="requestTypePOST" value="POST"><label for="requestTypePOST">POST</label>
</div>
<div>
<label for="data">Raw Data:</label>
<textarea id="data" name="data"></textarea>
</div>
<button onclick="add_field();return false;">Add Field</button>
</form>
<form type="multipart/form-encoded" name="frm" id="frm">
<div id="custom">

</div>
<div id="files">

</div>

<button onclick="add_file();return false;">Add File</button>
<button onclick="dosubmit();return false;">Submit</button>
</form>
<script type="text/javascript">
function add_file(){
    var nameoffile = prompt("Enter field name for new file", "default");
    if (nameoffile){
       $('#files').append('<div><input type="file" name="'+nameoffile+'"></div>');
    }
}
function add_field(){
    var nameoffield = prompt("Enter field name for new field");
    if (nameoffield){
       $('#custom').append('<div><label>'+nameoffield+'</label><input type="text" name="'+nameoffield+'"></div>');
    }
}

function dosubmit(){
    var frm = $('#frm').get(0);
    frm.action = $('#url').val();   
    frm.method = $('input[name=requestType]:checked').val();   
    var xhr = new XMLHttpRequest();
    xhr.open(frm.method, frm.action, true)
    if (true){
      var data = $('#data').val();
	  xhr.send(data);
    } else {
        alert('oops');
    }  
    if (xhr.status == 200){
        alert(xhr.responseXML);
    }
}
var topWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                   .getInterface(Components.interfaces.nsIWebNavigation)
                   .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
                   .rootTreeItem
                   .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                   .getInterface(Components.interfaces.nsIDOMWindow);
var BusinessDataChrome = topWindow.BusinessDataChrome;                   
</script>
</body>
</html>
